<template>
    <div>
        <el-menu
                style="width: 200px;min-height: calc(100vh - 50px)"
                :default-active="path"
                router
                class="el-menu-vertical-demo"
        >
            <el-sub-menu index="1-4" v-if="user.role ===1">
                <template #title>
                    <span>系统管理</span>
                </template>
                <el-menu-item index="/user" >
                    <span>用户管理</span>
                </el-menu-item>
            </el-sub-menu>
            <el-menu-item index="/resource">
                <span>资源管理</span>
            </el-menu-item>
            <el-menu-item index="/blog">
                <span>博客管理</span>
            </el-menu-item>
            <el-menu-item index="/resourceAuditing">
                <span>待审核管理</span>
            </el-menu-item>
        </el-menu>
    </div>
</template>


<script>
    import request from "../utils/request";

    export default {
        name: "Aside",
        data(){
            return {
                user:{},
                path: this.$route.path  //设置默认高亮菜单
            }
        },
        created() {
            let userStr = sessionStorage.getItem("user") || "{}"
            this.user = JSON.parse(userStr)
            // 请求服务端，确认当前登录用户的 合法信息
            request.get("/user/" + this.user.id).then(res => {
              if (res.code === '0') {
                this.user = res.data
              }
            })
        }
    }

</script>

<style scoped>

</style>